#!/usr/bin/perl
#Yes, this doesn't work! This is only template :)

use Socket;
#use strict; # :-/

our $ip=shift;
our $port=... #<<<<<<<< FIXME

sub hack #Main sub!
{
    my $s=shift;
    # $s - is a socket
    # print $s ...
    # <$s>
    #
    # recv($s,$str,10000,0)
    # send($,$str,0);
    # print STDERR "Debug message!";
    
    ######################## FIXME ########################
    while ( >>Enemy flags<< ) #<<<<<<<<<<<
    {
	>> Hack hack hack <<
	<< Another hack <<
	print "$flag\n"; #Horay!
    }
    ######################## FIXME ########################    
}



sub make_socket #just a socket connection
{
    my $sock;
    my $remote  = $ip;
    my $port    = $port;
    my $iaddr   = inet_aton($remote) or die("no host: $remote");
    my $paddr   = sockaddr_in($port, $iaddr);

    my $proto   = getprotobyname('tcp');
    socket($sock, PF_INET, SOCK_STREAM, $proto)  or die("socket: $!");
    connect($sock, $paddr) or die("connect: $!");

    select $sock;
    $|++;
    select STDOUT;

    return $sock;
}


our $s=make_socket();
hack($s);
shutdown($s,2); #Bye
